package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.eschool.model.Course;
import com.eschool.model.Room;

public class CourseDataModel extends ListDataModel<Course> implements SelectableDataModel<Course>, Serializable {  

    public CourseDataModel() {
    }

    public CourseDataModel(List<Course> data) {
        super(data);
    }
    
    @Override
    public Course getRowData(String rowKey) {
        List<Course>  courses = (List<Course>) getWrappedData();
        
		for (Course course : courses) {
            if(Integer.toString(course.getCourseId()).equals(rowKey))
                return course;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(Course course) {
        return course.getCourseId();
    }
}